﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chaos.view.lobby
{
    /// <summary>
    /// Interaction logic for lobby.xaml
    /// </summary>
    public partial class lobby : UserControl
    {
        public lobby()
        {
            InitializeComponent();
        }

        private void randomize_Click(object sender, RoutedEventArgs e)
        {
            network.gameclient c = System.Windows.Application.Current.FindResource("game_client") as network.gameclient;
            if (c != null)
            {
                messages.request_assign_factions_randomly msg = new messages.request_assign_factions_randomly();
                c.sendmessage(msg);
            }
        }

        public Point DragStart { get; set; }
        public bool IsDragging { get; set; }
        
        private drag.manager FindDragManager(UIElement uielement)
        {
            DependencyObject parent = uielement as DependencyObject;
            while (parent != null)
            {
                if (parent.GetType() == typeof(drag.manager))
                {
                    drag.manager m = parent as drag.manager;
                    return m;
                }
                parent = VisualTreeHelper.GetParent(parent);
            }   
            return null;
        }
        
        private void playerlist_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            object item = playerlist.SelectedItem;
            if (item != null)
            {
                DragDrop.DoDragDrop(playerlist, item, DragDropEffects.Move);
            }
        }
    }
}
